package com.ruoyi.web.controller.market.extend;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.ChannelUnionBaseInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.extend.service.IChannelUnionBaseInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.ChannelUnionBaseInfoWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 渠道联登基本信息Controller
 *
 * @author ruoyi
 * @date 2023-06-08
 */
@Controller
@RequestMapping("/extend/Unionbaseinfo")
public class ChannelUnionBaseInfoController extends BaseController {
    private String prefix = "extend/Unionbaseinfo";

    @Autowired
    private IChannelUnionBaseInfoService channelUnionBaseInfoService;

    @RequiresPermissions("extend:Unionbaseinfo:view")
    @GetMapping()
    public String Unionbaseinfo() {
        return prefix + "/Unionbaseinfo";
    }

    /**
     * 查询渠道联登基本信息列表
     */
    @RequiresPermissions("extend:Unionbaseinfo:view")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ChannelUnionBaseInfo channelUnionBaseInfo) {
        startPage();
        List<Map<String, Object>> mapList = channelUnionBaseInfoService.selectChannelUnionBaseInfoListMap(channelUnionBaseInfo);
        mapList = new ChannelUnionBaseInfoWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出渠道联登基本信息列表
     */
    @RequiresPermissions("extend:Unionbaseinfo:export")
    @Log(title = "渠道联登基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ChannelUnionBaseInfo channelUnionBaseInfo) {
        List<ChannelUnionBaseInfo> list = channelUnionBaseInfoService.selectChannelUnionBaseInfoList(channelUnionBaseInfo);
        ExcelUtil<ChannelUnionBaseInfo> util = new ExcelUtil<ChannelUnionBaseInfo>(ChannelUnionBaseInfo.class);
        return util.exportExcel(list, "渠道联登基本信息数据");
    }

    /**
     * 新增渠道联登基本信息
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存渠道联登基本信息
     */
    @RequiresPermissions("extend:Unionbaseinfo:add")
    @Log(title = "渠道联登基本信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ChannelUnionBaseInfo channelUnionBaseInfo) {
        return toAjax(channelUnionBaseInfoService.insertChannelUnionBaseInfo(channelUnionBaseInfo));
    }

    /**
     * 修改渠道联登基本信息
     */
    @RequiresPermissions("extend:Unionbaseinfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        ChannelUnionBaseInfo channelUnionBaseInfo = channelUnionBaseInfoService.selectChannelUnionBaseInfoById(id);
        mmap.put("channelUnionBaseInfo", channelUnionBaseInfo);
        return prefix + "/edit";
    }
 /**
     * 修改渠道联登基本信息
     */
    @RequiresPermissions("extend:Unionbaseinfo:look")
    @GetMapping("/view/{id}")
    public String view(@PathVariable("id") String id, ModelMap mmap) {
        ChannelUnionBaseInfo channelUnionBaseInfo = channelUnionBaseInfoService.selectChannelUnionBaseInfoById(id);
        mmap.put("channelUnionBaseInfo", channelUnionBaseInfo);
        return prefix + "/view";
    }

    /**
     * 修改保存渠道联登基本信息
     */
    @RequiresPermissions("extend:Unionbaseinfo:edit")
    @Log(title = "渠道联登基本信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ChannelUnionBaseInfo channelUnionBaseInfo) {
        return toAjax(channelUnionBaseInfoService.updateChannelUnionBaseInfo(channelUnionBaseInfo));
    }

    /**
     * 删除渠道联登基本信息
     */
    @RequiresPermissions("extend:Unionbaseinfo:remove")
    @Log(title = "渠道联登基本信息", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(channelUnionBaseInfoService.deleteChannelUnionBaseInfoByIds(ids));
    }




}
